// 注册多语言
export default (locale) => {
    const localeData = JSON.parse(JSON.stringify(locale))
    Promise.all([import('@inbiz/core'), import('@inbiz/render')]).then(([{ GlobalRegistry }, { transferLocalsToCommon }]) => {

        const changeList = {
            "permission": "permissionview",
            "personalinfo": "personal",
            "docselect": "docConfig",
            "eformstaticlist": "eformstaticlistview",
            "eformdynamiclist": "eformdynamiclistView",
            "tree": "treeview",
            "treeselect": "treeselectview",
            "table": "tableview",
            "bibarMap": "barmap",
            "bilineMap": "linemap",
            "eformbutton": "button",
            "eformbuttongroup": "buttongroup",
        } as Record<string, string>;

        let allCom = {} as Record<string, any>;
        Object.keys(localeData).forEach((newComKey: string) => {
            const lowKey = newComKey.toLowerCase()
            const oldName = changeList[lowKey];
            if (oldName) {
                allCom = {
                    ...allCom,
                    [oldName]: localeData[newComKey],
                    [newComKey]: localeData[newComKey]
                }
            } else {
                allCom = {
                    ...allCom,
                    [newComKey]: localeData[newComKey]
                }
            }
        });

        GlobalRegistry.registerDesignerLocales(
            ...transferLocalsToCommon(allCom),
        );
    })
}